<?php

class IndexController extends YouNet_Controller_Action
{
	function indexAction()
	{
        if (!Core_Util::isFacebookRequest())
        {
            $this->disableAutoRender();
            if ($this->_social->hasAppRequest())
			{
				$data = $this->_social->getAppRequestData();
				if (isset($data))
				{
					$data			= json_decode($data, true);
					$id_entry		= $data['id_object'];                    
					$id_user_ref	= !empty($data['id_ref'])?$data['id_ref']:ID_USER_CHEAT_FOR_COUNT_SHARE;
					
					$params = array(
						'target'	=> 'detail',
						'id_entry'	=> $id_entry
					);
                    if (empty($id_entry)) {
                        $params = array(
                            'target'	=> 'view'
                        );
                    }
					//Disable only increase if:
					//Existing id_user_ref & and correct id_entry
					//Core_Model_DbTable_Entries::getInstance()->increaseShareNumber($id_entry);
					
					$ns = Zend_Registry::get('session');
					$ns->id_entry			= $id_entry;
					$ns->id_user_ref		= $id_user_ref;
					$params['id_user_ref']	= $id_user_ref;
					
					YouNet_Util::parentRedirect($this->_social->pageUrl($params, $data['id_page']));
				}	
			}
            $this->_forward('list','manage','contest');
        }		
	}
}
